package parser;
import antlr.RecognitionException;
import antlr.Token;

class Binary extends Expr {
    
    Expr left;
    Expr right;
    int opID;
    
    Binary(Expr left, String op, Expr right) {
        this.left = left;
        this.opID = NameTable.getOperatorIndex(op);
        this.right = right;
    }
     
    void write(ByteStream out) throws RecognitionException {
        left.write(out);
        right.write(out);
        out.write(Opcodes.BINARY);
        out.write(opID);
    }
           
    void writeLHS(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot assign to binary operator");
    }

    void delete(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot delete rvalue");
    }
    
}
